<?php

/*

  Action	$5

  +1 Card; +2 Actions
  If there are one or more empty Supply piles, +1 Card. If there are two or more, +$1 and +1 Buy.

 */

class City extends Card implements iAction, iKingdom, iProsperity {

    public function __construct() {
        parent::__construct("City", 5);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+2 Actions",
            "If there are one or more empty Supply piles, +1 Card. If there are two or more, +$1 and +1 Buy.");
    }
    
    public function play(Game $game, $isRealCard) {
        $numOfEmptyPiles = $game->numberOfEmptyPiles();

        if ($numOfEmptyPiles == 0) {
            $game->addActions(2);
            $drawed_cards = $game->drawCards(1);
             ScreenDisplay::addScreenMessage($game, true, "get +2 actions and draw " . nicePrint($drawed_cards), " gets +2 actions and draws ".sizeof($drawed_cards)." cards");
        } else if ($numOfEmptyPiles == 1) {
            $game->addActions(2);
            $drawed_cards = $game->drawCards(2);
             ScreenDisplay::addScreenMessage($game, true, "get +2 actions and draw " . nicePrint($drawed_cards), " gets +2 actions and draws ".sizeof($drawed_cards)." cards");
        } else if ($numOfEmptyPiles >= 2) {
            $game->addActions(2);
            $drawed_cards = $game->drawCards(2);
            $game->addBuys(1);
            $game->addMoney(new Price(1));
             ScreenDisplay::addScreenMessage($game, true, "get +2 actions, +1 buy, +1$ and draw " . nicePrint($drawed_cards) , " gets +2 actions, +1 buy, +1$ and draws ".sizeof($drawed_cards)." cards");
        }

		$game->cardActionFinished();
        return true;
    }

}

?>